package com.ljp.usercenter.exception;

import com.ljp.usercenter.common.ErrorCode;

/**
 * ClassName: BusinessException
 * Package: com.ljp.usercenter.exception
 * Description: 自定义异常类,给原本的RuntimeException扩充了两个字段
 *
 * @Author: ljp
 * @Create: 2023/4/30-下午 08:51
 * @Version: 1.0
 */
public class BusinessException extends RuntimeException{
    /**
     * 状态码
     */
    private final int code;

    /**
     * 描述
     */
    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode,String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
